package main

import (
	"fmt"
	"golang.org/x/crypto/bcrypt"
)

func main() {
	pass := "secret"
	hashPassword, _ := HashPassword(pass)
	fmt.Println(hashPassword)

	fmt.Println(CheckPasswordHash(pass, hashPassword))
}
func CheckPasswordHash(pass, hash string) bool {
	err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(pass))
	return err == nil
}
func HashPassword(pass string) (string, error) {
	password, err := bcrypt.GenerateFromPassword([]byte(pass), 14)
	return string(password), err
}
